home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Mac Game Programming Gurus / TricksOfTheMacGameProgrammingGurus.iso / More Source / C⁄C++ / Legend / Legend source / support2.c < prev   
Encoding:
C/C++ Source or Header  |  1994-10-26  |  1.5 KB  |  72 lines  |  [TEXT/KAHL]

  1. /* support items*/
  2. #include <Quickdraw.h>
  3.  
  4.  
  5.  
  6. #define OK_ITEM    1
  7.  
  8. /*DrawOKButton*/
  9. /*this routine draws a hilite around the first item
  10. it assumes item 1 is the OK button*/
  11.  
  12. DrawOKButton(theDialog)
  13. DialogPtr    theDialog;
  14. {
  15.     short    itemType;
  16.     Rect    itemRect;
  17.     Handle    item;
  18.     GrafPtr    oldPort;
  19.     GetDItem(theDialog,OK_ITEM,&itemType,&item,&itemRect);
  20.     GetPort(&oldPort);
  21.     SetPort(theDialog);    
  22.     PenSize(3,3);
  23.     InsetRect(&itemRect,-4,-4);
  24.     FrameRoundRect(&itemRect,16,16);
  25.     PenNormal();
  26.     SetPort(oldPort);
  27. }
  28.  
  29.  
  30.  
  31. /***dialogfilter***/
  32. /*standard dialog filter*/
  33. /*returns 1:OK 2:Cancel or returns to standard*/
  34. pascal Boolean diafilter(DialogPtr theDlg,EventRecord *theEvent,
  35.     short *itemHit )
  36. {
  37.     
  38.     if ( theEvent->what != keyDown )    // just looking for keystrokes
  39.         return(FALSE);
  40.  
  41.     switch ( (theEvent->message) & charCodeMask ) {
  42.         case 0x0d:    // Return pressed or ...
  43.         case 0x03:    // ... Enter pressed
  44.             *itemHit = ok;
  45.             return( TRUE );    // Note: pascal-style TRUE
  46.         case 0x1b:
  47.             *itemHit = cancel;    // Esc pressed
  48.             return( TRUE );
  49.         default:
  50.             return( FALSE );    // all others
  51.     }
  52. }
  53.  
  54.  
  55.  
  56.  
  57. // ===========  this routine frames dialog item #1 =============
  58. /*this example is straight out of ModalDialog in Think Reference 2.0
  59. it is probably better to use this instead of drawOKbutton
  60. it uses a user item and procedure to draw a frame around item 1*/
  61. pascal void okitemproc(WindowPtr theDlg,short theItem )
  62. {
  63.     Rect    iRect;
  64.     Handle    iHndl;
  65.     short    iType;
  66.  
  67.     GetDItem (theDlg, 1, &iType, &iHndl, &iRect );     // item #1
  68.     PenSize( 3,3 );
  69.     InsetRect( &iRect, -4,-4);
  70.     FrameRoundRect( &iRect, 16,16 );
  71. }
  72.